#!/bin/sh

# Displays number of unread mail and an loading icon if updating.
# When clicked, brings up `mutt`.

case $BUTTON in
	1) setsid -f "$TERMINAL" -e mutt ;;
	2) setsid -f chkMailbox >/dev/null ;;
	3) notify-send "📬 邮件模块" "\- 查看未读邮件
- 图标[📬:📩]表示邮件正在同步中...
- 左键点击打开mutt
- 中键点击立即同步邮件" ;;
	6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

pidof mbsync >/dev/null 2>&1 && echo "📬:📩" ||
{
        unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f 2>/dev/null | wc -l 2>/dev/null)"
        [ "$unread" != "0" ] && mpv --no-video --no-terminal ./email.recv.mp3 && notify-send "📬 温馨提示：您有($unread)封未读邮件"
        echo "📬:$unread(Mail)"
}


